package com.example.demo.service;

import com.example.demo.entity.PersonBean;
import com.example.demo.entity.PersonSearchBean;
import com.example.demo.mapper.PersonMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class PersonService {
    @Autowired
    PersonMapper personMapper;
    public List<PersonBean> personFindAll() {
        return personMapper.personFindAll();
    }

    public List<PersonBean> personSearchTask(PersonSearchBean personSearchBean) {
        return personMapper.personSearch(personSearchBean);
    }

    public int personSearchCount(PersonSearchBean personSearchBean) {
        return personMapper.personSearchCount(personSearchBean);
    }

    public boolean personSaveTask(PersonBean personBean) {
        if (personBean.getId() > 0) {
            return personMapper.personUpdate(personBean);
        } else {
            return personMapper.personInsert(personBean);
        }
    }

    public boolean personDelTask(int id) {
        return personMapper.personDelete(id);
    }
}
